<!DOCTYPE html>
<html class="no-js" lang="zh_CN">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">

    <title>${system_admin_title}</title>
    #required_css
</head>

<body>#loading


<div class="app $!layout">
    <!-- 头部菜单 -->
    #header
    <section class="layout">
        <!-- 菜单 -->
        #sidebar
        <!-- 内容主体 -->
        <section class="container">
            <section class="main-content">
                <!-- 主体操作栏 -->
                <header class="header navbar">
                    <!-- 左按钮区 -->
                    <div class="btn-group tool-button">
                        <a class="btn btn-primary navbar-btn" href="$!basePath/system/unit"><i
                                class="ti-angle-left"></i> 返回</a>
                    </div>
                </header>
                <div class="content-wrap">
                    <div class="wrapper">
                        <section class="panel pt20 pl20 pr20">
                            <form id="unitEditForm" role="form" class="form-horizontal parsley-form" data-parsley-validate action="$!basePath/system/unit/edit/do" method="post">
                                <input type="hidden" name="id" value="$!unit.id"/>
                                <div class="row mb10">
                                    <div class="col-lg-12 col-md-12">
                                        <div class="form-group has-feedback">
                                            <label for="parentId" class="col-sm-1 control-label">上级组织</label>
                                            <div class="col-sm-10">
                                                <div class="input-group">
                                                    <input id="parentId" type="text" class="form-control" placeholder="上级组织，不选择默认为顶级组织" disabled value="$!parentUnit"/>
                                                    <span class="input-group-btn">
                                                        <button type="button" class="btn btn-primary" onclick="doSelectParentUnit()" #ifDisabled($!noUnit)><i class="ti-plus"></i> 选择</button>
                                                    </span>
                                                </div>
                                                <input type="hidden" name="parentId" value="$!unit.parentId">
                                            </div>
                                        </div>
                                        <div class="hr-line-dashed"></div>
                                        <div class="form-group">
                                            <label for="name" class="col-sm-1 control-label">名称<span class="text-danger">*</span></label>
                                            <div class="col-sm-10">
                                                <input type="text" class="form-control" name="name" data-parsley-required="true" placeholder="#springMessage('system.sys.unit.name')" value="$!unit.name">
                                            </div>
                                        </div>
                                        <div class="hr-line-dashed"></div>
                                        <div class="form-group">
                                            <label for="address" class="col-sm-1 control-label">#springMessage('system.sys.unit.addr')</label>
                                            <div class="col-sm-10">
                                                <input type="text" name="address" class="form-control" placeholder="组织所在地址" value="$!unit.address">
                                                <p class="help-block no-m">例如：安徽省合肥市高新区长江西路001号</p>
                                            </div>
                                        </div>
                                        <div class="hr-line-dashed"></div>
                                        <div class="form-group">
                                            <label for="contact" class="col-sm-1 control-label">#springMessage('system.sys.unit.contact')</label>
                                            <div class="col-sm-4">
                                                <input type="text" name="contact" class="form-control" placeholder="联系人姓名" value="$!unit.contact">
                                            </div>
                                            <label for="mobile" class="col-sm-1 control-label">#springMessage('system.sys.unit.phone')</label>
                                            <div class="col-sm-5">
                                                <input type="text" name="mobile" class="form-control" placeholder="固定电话、手机号码等" value="$!unit.mobile">
                                            </div>
                                        </div>
                                        <div class="hr-line-dashed"></div>
                                        <div class="form-group">
                                            <label for="email" class="col-sm-1 control-label">电子邮件</label>
                                            <div class="col-sm-4">
                                                <input type="text" name="email" class="form-control" placeholder="格式：xxx@xxx.xx" data-parsley-type="email" data-parsley-trigger="change" value="$!unit.email">
                                            </div>
                                            <label for="web" class="col-sm-1 control-label">网站地址</label>
                                            <div class="col-sm-5">
                                                <input type="text" name="web" class="form-control" placeholder="http://" value="$!unit.web">
                                            </div>
                                        </div>
                                        <div class="hr-line-dashed"></div>
                                        <div class="form-group">
                                            <label for="enabled" class="col-sm-1 control-label">是否启用</label>
                                            <div class="col-sm-4 switcha">
                                                <div class="mr15">
                                                    <input type="checkbox" name="enabled" class="js-switch-blue" #ifChecked($!unit.enabled)>
                                                </div>
                                            </div>
                                            #if($!isSystemUnit == true)
                                            <label for="enabled" class="col-sm-1 control-label">系统组织</label>
                                            <div class="col-sm-4 switcha">
                                                <div class="mr15">
                                                    <input type="checkbox" name="system" class="js-switch-blue"
                                                           #if($!unit.system)checked="checked" #end>
                                                </div>
                                            </div>
                                            #end
                                        </div>
                                    </div>
                                    <div class="col-lg-12 col-md-12 col-sm-12">
                                        <div class="hr-line-dashed"></div>
                                        <div class="form-group text-center">
                                            <div>
                                                <button class="btn btn-primary btn-form-submit btn-parsley"
                                                        data-loading-text="正在提交...">立即提交
                                                </button>
                                                <button type="reset" class="btn btn-default btn-outline">重置</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </section>
                    </div>
                </div>
                <a class="exit-offscreen"></a>
            </section>
        </section>
    </section>
</div>
#required_js

<!-- 页面组件脚本 -->
<script src="$!basePath/framework/plugins/count-to/jquery.countTo.js"></script>
<script src="$!basePath/framework/plugins/switchery/switchery.js"></script>

<!-- 本页面脚本 -->
<script src="$!basePath/framework/js/form/form.js"></script>
<script src="$!basePath/framework/js/view/toast.js"></script>
<script src="$!basePath/framework/js/view/tree.js"></script>
<script src="$!basePath/framework/js/form/validator.js"></script>
<script src="$!basePath/framework/js/common/unit.js"></script>
<script type="text/javascript">
    function doSelectParentUnit(){
        ns.common.unit.select({
            showTopUnit : true,
            callback : function(units){
                var unit = units[0];
                $("#unitEditForm #parentId").val(unit.name);
                $("#unitEditForm input[name='parentId']").val(unit.id);
            }
        })
    }
    $(function () {
        $('#unitEditForm').ajaxForm({
            beforeSubmit: function (arr, $form, options) {
                $form.find("button:submit").button("loading");
            },
            success: function (data, statusText, xhr, $form) {
                if (data.success == true) {
                    Toast.success("组织修改成功，3秒后返回组织组织首页", function () {
                        //返回上级菜单
                        window.location.href = "$!basePath/system/unit";
                    });
                    setTimeout(function () {
                        //返回上级菜单
                        window.location.href = "$!basePath/system/unit";
                    }, 3000);
                } else {
                    Toast.error(data.message);
                    $form.find("button:submit").button("reset");
                }

            }
        });
    });

</script>
#loading_close
</body>
</html>
